<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div class="wrap-content-dialog">
    <form class="form-horizontal" role="form" id="form-edit" action="url/resource/update.do">
            <input type="hidden" name="id" value="${objBean.id }" />
            <div class="form-group m-b-10">
			    <label for="col1" class="col-sm-2 control-label">资源名称</label>
			    <div class="col-sm-10 p-l-0">
			      <input type="text" class="form-control mix-require" name="name" value="${objBean.name }" data-label-name="资源名称" id="col1" />
			    </div>
			</div>
			<div class="form-group m-b-10">
			    <label for="col2" class="col-sm-2 control-label">URL</label>
			    <div class="col-sm-10 p-l-0">
			      <input type="text" class="form-control mix-require" name="url" data-label-name="URL" value="${objBean.url }" id="col2" />
			    </div>
			</div>
			<div class="form-group m-b-10">
			    <label for="col3" class="col-sm-2 control-label">资源类型</label>
			    <div class="col-sm-10 p-l-0">
			      <select class="form-control mix-select" name="urlResType" id="col3" data-default-value="${objBean.urlResType }" data-uri="dict/items/url_resource_type.do"></select>
			    </div>
			</div>
			<div class="form-group m-b-10">
			    <label for="col4" class="col-sm-2 control-label">状态</label>
			    <div class="col-sm-10 p-l-0">
			       <select class="form-control mix-select" name="state" id="col4" data-default-value="${objBean.state }" data-uri="dict/items/valid_state.do"></select>
			    </div>
			</div>
			<div class="form-group m-b-10">
				<fieldset class="normal-fieldset">
				    <legend>操作权限列表</legend>
				    <ul class="list-unstyled checked-op-flag-wrap">
				       <c:if test="${mixResp.result == '1'}">
				          <c:forEach var="data" items="${mixResp.datas }" varStatus="st">
				             <li class="checkbox select-op-flag "><label for="${data[0] }">
				             <input type="checkbox" id="${data[0] }" ${(not empty data[3])?'checked':''} name="resOpFlags[${st.index }].opFlagId" value="${data[0] }" data-action-name="${data[1] }" /> ${data[2]}</label>
				             <span class="checked-extends-input ${ (not empty data[3])?'':'hide'}">
				                 <input name="resOpFlags[${st.index }].id" value="${data[8]}" type="hidden" />
				                 <c:if test="${data[1] != 'delete' }">
				                 <label for="">页面URL：</label>
					             <input name="resOpFlags[${st.index }].viewUrl" value="${data[5]}" class="form-control" type="text" />
					             <input  name="resOpFlags[${st.index }].viewUrlResId" value="${data[4]}" type="hidden" />
				                 </c:if>
					             <label for="">提交URL：</label>
					             <input name="resOpFlags[${st.index }].postUrl" value="${data[7]}" class="form-control" type="text" />
					             <input  name="resOpFlags[${st.index }].postUrlResId" value="${data[6]}" type="hidden" />
				             </span>
				             </li>
				          </c:forEach>
				       </c:if>
				    </ul>
				</fieldset>
			</div>
			<div class="dialog-footer-btns">
			      <button type="button" class="btn btn-primary mix-data-submit" data-target-form="#form-edit" data-is-iframe="yes">
			      <i class="glyphicon glyphicon-ok-sign"></i> 确定</button>
			</div>
   </form>
   <script type="text/javascript">
  $(function(){
	  setTimeout(function() {
	    	$(".select-op-flag input").click(function(){
	    		var that = $(this);
	    		var checked = $(this).prop("checked");
	    		var $checkedExtendsInput = $(this).parent().next();
	    		if(checked) {
	    			var url = utils.handleNull($("#col2").val());
	    			if(utils.isNotEmpty(url)) {
	    				url = url.substring(0, url.lastIndexOf("/"));
	    			}
	    			$checkedExtendsInput.parent().addClass("op-flag-checked");
		    		$checkedExtendsInput.find("input").each(function(){
		    			$(this).prop("disabled",false);
		    			if($(this).hasClass("form-control")) {
		    				var thisValue = $(this).val();
			    			if(utils.isEmpty(thisValue)) {
			    				var actionName = that.data("action-name");
			    				if(actionName != 'refresh') {
			    					actionName += ".do";
			    					if(utils.isEmpty(url)) {
					    				$(this).val(actionName);
					    			} else {
					    				$(this).val(url+"/"+actionName);
					    			}
			    				}
			    			}
		    			}
		    		});
		    		$checkedExtendsInput.removeClass("hide");
	    		} else {
	    			$checkedExtendsInput.parent().removeClass("op-flag-checked");
	    			if($checkedExtendsInput.find("input").next().hasClass("mix-star-require")) {
	    	    		$checkedExtendsInput.find("input").next().remove();
	    	    	}
	    			$checkedExtendsInput.find("input").prop("disabled",true);
	    			$checkedExtendsInput.addClass("hide");
	    		}
	    	});
	    }, 300);
  });
</script>
</div><!-- wrap-content-dialog -->